package com.pro.exam.web.controller;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.test.web.servlet.result.JsonPathResultMatchers;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.pro.exam.common.controller.BaseController;
import com.pro.exam.common.utils.DataUtils;
import com.pro.exam.web.service.DictTransService;
import com.pro.exam.web.service.TranslateService;

@Controller
public class IndexController extends BaseController{
	@Autowired
	TranslateService translateService;
	@Autowired
	DictTransService dictTransService;
	
	@RequestMapping("/index.html")
	public String index(Model m,HttpServletRequest request){
		
		return "web/index";
	}
	@RequestMapping("/translate.html")
	public String translate(Model m,HttpServletRequest request){
		String content=request.getParameter("content");
		String language=request.getParameter("language");
		System.out.println("------------------"+content+"------------------");
		try {
			m.addAttribute("translate_content", translateService.translate(language, content));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("------------------11111111111------------------");
		m.addAttribute("content", content);
		m.addAttribute("language", language);
		System.out.println("------------------22222222222------------------");
		return "web/index";
	}
	
	@RequestMapping("/generate.html")
	public String generate(Model m,HttpServletRequest request){
		translateService.generate();
		return "web/index";
	}
	
}
